/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package appGUI;

import java.awt.Color;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.Graphics;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPanel;

/**
 *
 * @author Picto
 */
public class LetterGrid extends JPanel {

    InputStream fontLocation = this.getClass().getResourceAsStream("/appGUI/resources/DS-DIGI.TTF");
    Font font;
    ArrayList<String> disabledLetters = new ArrayList<String>();

    public LetterGrid() {
        setBackground(Color.BLACK);
        try {
            font = Font.createFont(Font.TRUETYPE_FONT, fontLocation);
        } catch (FontFormatException ex) {
            Logger.getLogger(LetterGrid.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(LetterGrid.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        g.setColor(Color.GREEN);
        g.setFont(font.deriveFont(50f));
        printLetter("a", 6, 37, g);
        printLetter("b", 42, 37, g);
        printLetter("c", 78, 37, g);
        printLetter("d", 114, 37, g);
        printLetter("e", 150, 37, g);
        printLetter("f", 186, 37, g);
        printLetter("g", 222, 37, g);
        printLetter("h", 6, 77, g);
        printLetter("i", 42, 77, g);
        printLetter("j", 78, 77, g);
        printLetter("k", 114, 77, g);
        printLetter("l", 150, 77, g);
        printLetter("m", 186, 77, g);
        printLetter("n", 222, 77, g);
        printLetter("o", 6, 117, g);
        printLetter("p", 42, 117, g);
        printLetter("q", 78, 117, g);
        printLetter("r", 114, 117, g);
        printLetter("s", 150, 117, g);
        printLetter("t", 186, 117, g);
        printLetter("u", 222, 117, g);
        printLetter("v", 6, 157, g);
        printLetter("w", 42, 157, g);
        printLetter("x", 78, 157, g);
        printLetter("y", 114, 157, g);
        printLetter("z", 150, 157, g);
        g.drawRect(0, 0, 179, 160);
        g.drawRect(179, 0, 71, 120);
        //Vertical lines
        g.drawLine(35, 0, 35, 160);
        g.drawLine(71, 0, 71, 160);
        g.drawLine(107, 0, 107, 160);
        g.drawLine(143, 0, 143, 160);
        g.drawLine(215, 0, 215, 120);
        //Horizontal line
        g.drawLine(0, 40, 250, 40);
        g.drawLine(0, 80, 250, 80);
        g.drawLine(0, 120, 179, 120);
    }

    public void disableLetter(String letter) {
        disabledLetters.add(letter);
    }
    
    public void enableAllLetters(){
        disabledLetters.clear();
    }

    public void printLetter(String letter, int x, int y, Graphics g) {
        if (disabledLetters.contains(letter)) {
            g.setColor(Color.GRAY);
            g.drawString(letter, x, y);
            g.setColor(Color.GREEN);
        } else {
            g.drawString(letter, x, y);
        }
    }
}
